package mapper;

import jdk.nashorn.internal.objects.annotations.Setter;
import lombok.NoArgsConstructor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import pojo.User;

import java.util.List;





public interface UserMapper {
    /**
     * 查询全部User
     * @return
     */
    @Select("select * from t_user")
    List<User> selectAll();

    /**
     * 查询单个
     * @param id
     * @return
     */
    @Select("SELECT * FROM t_user WHERE id = #{id}")
    User selectOne(int id);

    /**
     * 插入一个User
     */
    @Insert("INSERT into t_user(id,username,fullname,password,address) VALUES(#{id},#{username},#{fullname},#{password},#{address})")
    void insertOne(User user);

    /**
     * 删除一个User
     */
    @Delete("DELETE FROM t_user WHERE id = #{id}")
    void deleteOne(int id);

    /**
     * 修改一个User
     */
    @Update("update t_user set  username=#{username} , fullname = #{fullname} ," +
            "password=#{password} , address=#{address}" +
            "WHERE id = #{id}")
    void updateOne(User user);



}
